import React, { FC, useEffect, useState } from "react";
import { Space, Typography } from "antd";
import styles from "./Logo.module.scss";
import { Link } from "react-router-dom";
import { FormOutlined } from "@ant-design/icons";
import useGetUserInfo from "../hooks/useGetUserInfo";
import { HOME_PATHNAME,MANAGE_INDEX_PATHNAME } from "../router";

const { Title } = Typography;

const Logo: FC = () => {
    const { username, nickname } = useGetUserInfo();
    const [pathname, setPathname] = useState(HOME_PATHNAME)
    useEffect(() => {
        if (username) {
            setPathname(MANAGE_INDEX_PATHNAME)
        }
    },[username])
  return (
    <div className={styles.container}>
      <Link to={pathname}>
        <Space>
          <Title>
            <FormOutlined />
          </Title>
          <Title>
            <div className={styles.text}>星问卷</div>
          </Title>
        </Space>
      </Link>
    </div>
  );
};
export default Logo;
